#include "AiTextEdit.h"

#include <QPainter>
#include <QDebug>
#include <string>

using namespace std;

AiTextEdit::AiTextEdit(QWidget *parent) : QTextEdit(parent)
{
    // 开启鼠标追踪
    setMouseTracking(true); 

    // 禁止父窗口颜色影响子窗口颜色
    this->setAttribute(Qt::WA_StyledBackground);

    this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

    // 滚动条样式重定义-隐藏AiDialog
    m_scrollbar = new QScrollBar(Qt::Vertical);
    string verticalbar_qss = R"(
		QScrollBar{width:16px;background:rgb(255, 255, 255);margin:0px, 0px, 0px, 0px;}
		QScrollBar::handle:vertical{width:10px;background:rgba(162, 163, 165, 50%);border-radius:4px;min-height:40;}
              QScrollBar::handle:vertical:hover{width:10px;background:rgba(115,118,118, 50%);border-radius:4px;min-height:40;}
              QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical{background:rgb(255, 255, 255);border-radius:4px;}
              QScrollBar::top-arrow:vertical,QScrollBar::bottom-arrow:vertical{border: none;background: none;color: none;}
              QScrollBar::add-line:vertical{border:none;background:none;}
              QScrollBar::sub-line:vertical{border:none;background:none;})";
    m_scrollbar->setStyleSheet(QString::fromStdString(verticalbar_qss));

    this->setVerticalScrollBar(m_scrollbar);
    // 最低高度100
    this->setStyleSheet("background-color: rgb(255, 255, 255);border:none;");
}

// 析构
AiTextEdit::~AiTextEdit(){

}

